import axios from "axios"
let server= axios.create({
    baseURL:'/',
    timeout: 5000,
    headers:{'X-Custom-Header':'ahong'}

})

server.interceptors.request.use(function(config){
    let token = localStorage.getItem('token');
    config.headers.Authorization = `Bearer ${token}`
    return config
},function(error) {
    console.log('发送出错')
    Promise.reject(error)
})

server.interceptors.response.use(function(response) {
    console.log('响应成功')
    return response
},function(error) {
    console.error('响应出错')
    Promise.reject(error)
})


export default server